var service_common = require("common.js");

//对外公开的方法
module.exports = {
  getDaiLiMoney: getDaiLiMoney,
  getTeamMoney: getTeamMoney,
  getTeacherMoney: getTeacherMoney,
  daiLiWithdraw: daiLiWithdraw,
  teamWithdraw: teamWithdraw,
  teacherWithdraw: teacherWithdraw,
  getDaiLiWithdrawLog: getDaiLiWithdrawLog,
  getTeamWithdrawLog: getTeamWithdrawLog,
  getTeacherWithdrawLog: getTeacherWithdrawLog,
  helpWithDraw: helpWithDraw
}

/**
 * 获取代理余额
 */
function getDaiLiMoney(cb) {
  service_common.fetchData(
    service_common.getUrl("user.getDaiLiMoney"),
    {
      openid: getApp().globalData.openid
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}

/**
 * 获取战队余额
 */
function getTeamMoney(id, cb) {
  service_common.fetchData(
    service_common.getUrl("user.getTeamMoney"),
    {
      openid: getApp().globalData.openid,
      id: id
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}

/**
 * 获取讲师余额
 */
function getTeacherMoney(cb) {
  service_common.fetchData(
    service_common.getUrl("user.getTeacherMoney"),
    {
      openid: getApp().globalData.openid
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}

/**
 * 代理提现
 */
function daiLiWithdraw(money, cb) {
  service_common.fetchData(
    service_common.getUrl("user.daiLiWithdraw"),
    {
      openid: getApp().globalData.openid,
      money: money
    },
    function (res) {
      cb(res);
    },
    "GET", true
  )
}

/**
 * 战队提现
 */
function teamWithdraw(money, id, position, cb) {
  service_common.fetchData(
    service_common.getUrl("user.teamWithdraw"),
    {
      openid: getApp().globalData.openid,
      money: money,
      id: id,
      position: position
    },
    function (res) {
      cb(res);
    },
    "GET", true
  )
}

/**
 * 讲师提现
 */
function teacherWithdraw(money, cb) {
  service_common.fetchData(
    service_common.getUrl("user.teacherWithdraw"),
    {
      openid: getApp().globalData.openid,
      money: money
    },
    function (res) {
      cb(res);
    },
    "GET", true
  )
}

/**
 * 获取代理提现记录
 */
function getDaiLiWithdrawLog(page, cb) {
  service_common.fetchData(
    service_common.getUrl("user.getDaiLiWithdrawLog"),
    {
      openid: getApp().globalData.openid,
      page: page
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}
/**
 * 获取战队提现记录
 */
function getTeamWithdrawLog(page, team_id, cb) {
  service_common.fetchData(
    service_common.getUrl("user.getTeamWithdrawLog"),
    {
      openid: getApp().globalData.openid,
      page: page,
      team_id: team_id
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}
/**
 * 获取讲师提现记录
 */
function getTeacherWithdrawLog(page, cb) {
  service_common.fetchData(
    service_common.getUrl("user.getTeacherWithdrawLog"),
    {
      openid: getApp().globalData.openid,
      page: page
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}
/**
 * 借权支付
 */
function helpWithDraw(openid, code, which, cb) {
  service_common.fetchData(
    service_common.getUrl("user.helpWithDraw"),
    {
      openid: openid,
      page: code,
      which: which
    },
    function (res) {
      cb(res);
    },
    "GET"
  )
}